<template>
  <div>
    <el-dialog
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
      title="失败数据"
      width="750px"
      @close="close"
    >
      <div v-loading="loading">
        <el-table
          :data="list"
          border
          stripe
          style="width: 100%"
          size="small"
          element-loading-text="加载中"
          empty-text="暂无数据"
        >
          <el-table-column prop="memberName" label="姓名" />
          <el-table-column prop="phone" label="手机号" />
          <el-table-column prop="msg" label="原因" />
        </el-table>
        <!-- 分页 -->
        <pagination-direction
          v-if="paginationConfig.total!==0"
          :config="paginationConfig"
          @sizeschange="sizesChange"
          @pagechange="pageChange"
        />
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { memberBatchJobFailList } from '@/api/vip'
export default {
  data() {
    return {
      // 配置
      resolve: null,
      reject: null,
      // 分页配置
      paginationConfig: {
        direction: 'center', // 分页位置
        layout: 'total, sizes, prev, pager, next, jumper', // 分页类型
        pageSizes: [10], // 分页pages
        total: 0,
        page: 1, // 页数-默认1
        pageSize: 10 // 每页条数-默认10
      },
      // 状态
      dialogVisible: null,
      loading: false,
      // 数据
      row: null,
      list: []
    }
  },
  methods: {
    /**
       * 弹框相关
       */
    open({ row }) {
      this.row = row
      this.fetchData()
      this.show()
      return new Promise((resolve, reject) => {
        this.resolve = resolve
        this.reject = reject
      })
    },

    show() {
      this.dialogVisible = true
    },

    close() {},

    hide() {
      this.resolve = null
      this.reject = null
      this.dialogVisible = false
    },

    /**
       * 数据组
       */

    /**
       * 按钮组
       */
    // 获取数据
    fetchData(
      page = this.paginationConfig.page,
      pageSize = this.paginationConfig.pageSize
    ) {
      this.loading = true
      const params = {}
      params.jobId = this.row.id
      params.page = page
      params.pageSize = pageSize
      memberBatchJobFailList(params)
        .then(res => {
          this.list = res.data.list
          this.paginationConfig.total = res.data.total
          this.paginationConfig.page = res.data.pageNum
        })
        .finally(() => {
          this.loading = false
        })
    },

    // 分页sizes改变
    sizesChange() {
      this.fetchData()
    },

    // 分页page改变
    pageChange() {
      this.fetchData()
    }

    /**
       * 状态组
       */

    /**
       * 方法组
       */
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
</style>
